/**
 * 
 */
package org.extdev.device.ltr;

import org.extdev.connection.Connection;
import org.extdev.device.Device;
import org.extdev.libraries.ltr.LTR212APILibraryFacade;
import org.extdev.libraries.ltr.LTRAPIFacadeFactory;
import org.extdev.libraries.ltr.LTRException;
import org.extdev.protocol.Protocol;



/**
 * @author LAP
 *
 */
public class LTR212LibDevice extends Device {
	
	public static final int maxChannels = 8;
	
	private LTR212APILibraryFacade ltr212Facade;
	
	public LTR212LibDevice(Connection connection, Protocol<?,?> protocol, String serialNumber, short moduleNo) throws LTRException {
		ltr212Facade = LTRAPIFacadeFactory.getInstance().getLTR212ModuleFacade(serialNumber, moduleNo);
		setConnection(connection);
		setProtocol(protocol);
	}
	
	public void startDataReading() throws LTRException {
		ltr212Facade.start();
	}

	public void stopDataReading() throws LTRException {
		ltr212Facade.stop();
	}
	
	public void setDotsCount(int count) {
		ltr212Facade.setDataPointsCount(count);
	}
	
	public void setChannels(LTR212Channel channel) {
		ltr212Facade.addChannel(channel);
	}
	
	public void saveSettings() throws LTRException {
		ltr212Facade.setChannels();
		ltr212Facade.setADC();
	}
	
	public void setAC(boolean flag) {
		ltr212Facade.setAC(flag);
	}
	
	public boolean isAC() {
		return ltr212Facade.isAC();
	}
	
	public void setACQMode(int mode) {
		ltr212Facade.setACQMode(mode);
	}
	
	public int getACQMode() {
		return ltr212Facade.getACQMode();
	}
	
	public boolean isREF() {
		return ltr212Facade.isRef();
	}
	
	public void setREF(boolean flag) {
		ltr212Facade.setRef(flag);
	}
	
	public void removeChannel(int index) {
		ltr212Facade.removeChannel(index);
	}
	
	public void removeAllChannels() {
		ltr212Facade.removeAllChannels();
	}
	
	public void init() throws LTRException {
		ltr212Facade.inicilizeLTR212();
	}
}
